home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Subject: Re: stricmp()
- X-Nntp-Posting-Host: foley.ripco.com
- Message-ID: <DL3u99.9wH@rci.ripco.com>
- Sender: usenet@rci.ripco.com (Net News Admin)
- Organization: Ripco Internet BBS Chicago
- Date: Sat, 13 Jan 1996 05:36:45 GMT
- X-Ident-Sender: mambuhl
-
- jackal@gcomm.com (Jack Alvrus)
- in <8213293982604@demosys.gcomm.com> wrote:
-
- >stricmp() is an ANSI library function, right?...
-
- Wrong.
-
- >... So it should exhibit, if
- >not consistent, at least *documented* behavior, right?
-
- The premise is false, but the conclusion is none the less true. The
- behavior should be documented:
-
- ISO clause 4:
- "An implementation shall be accompanied by a document that defines
- all implementation defined characteristics and all extensions."
-
-
- >So, is stricmp("a","^") always less than zero or greater than zero, and
- >if neither, is there any documented behavior in this case?
-
- >I ask because '^' is *between* 'A' and 'a' in ASCII. So if stricmp()
- >always compares to upper case letters, stricmp("a","^") is always less
- >than zero. If it always compares to lower case letters,
- >stricmp("a","^") is always *greater* than zero.
-
- >My compiler's reference manual does not say one way or another, but a
- >quick test showed stricmp("a","^") < 0.
-
- >Any comments?
-
- Your implementation should have defined what a "case-insensitive"
- comparison is. Failing that, it has not met the requirement of ISO
- clause 4. In the absence of such documentation, I would assume for
- historical reasons* that the mapping was to upper case, but that
- assumption could be wrong.
-
- * [For ASCII representations]
- ASCII derives from the TTY codes. Many TTY devices had only upper
- case, so I would expect a mapping _when_ it occurred would be for ASCII
- to the 040-0137 (' ' through '_') range, and specifically the 0101-0132
- range ('A' through 'Z') for case-insensitivity of alpha chars. Notice
- that the printing representation of a control character x in the 0-037
- range is traditionally '^' followed by (x|0100) which is the 0100-0137
- range.
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-